﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;

namespace GetMovies
{
    public class GetMovies
    {
        string[] files;
        ArrayList temp;

        public GetMovies(string[] paths)
        {
            temp = new ArrayList();
            foreach (string p in paths) 
            {
                copyToTemp(Directory.GetFiles(p, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".avi") || s.EndsWith(".mkv") || s.EndsWith(".mp4") || s.EndsWith(".ts")));
            }
        }

        private void copyToTemp(IEnumerable<string> scan)
        {
            foreach (string s in scan)
            {
                temp.Add(s);
            }
        }

        public string[] getFileNames()
        {
            int i = 0;
            files = new string[temp.Count];
            string[] entry = new string[files.Length];
            temp.CopyTo(files);
            foreach (string f in files)
            {
                entry[i] = Path.GetFileName(f);
                i++;
            }
            return entry;
        }

        public string[] getFullPaths()
        {
            int i = 0;
            files = new string[temp.Count];
            string[] entry = new string[files.Length];
            temp.CopyTo(files);
            foreach (string f in files)
            {
                entry[i] = Path.GetFullPath(f);
                i++;
            }
            return entry;
        }    
    }
}
